package com.prs.crm.service.sys.impl;

import java.util.List;

import org.courser.Util;
import org.courser.service.ServiceSupportImpl;
import org.courser.ui.PaginationSupport;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;

import com.prs.crm.dao.sys.LogDao;
import com.prs.crm.domain.hr.Person;
import com.prs.crm.domain.sys.Log;
import com.prs.crm.domain.sys.LogItem;
import com.prs.crm.domain.sys.Module;
import com.prs.crm.service.sys.LogService;

public class LogServiceImpl extends ServiceSupportImpl<Log,LogDao> implements LogService {
	
	public 	void saveLog(Person person ,Module module)
	{
		Log log = new Log();
		log.setAccessTime(Util.nowFullTime());
		log.setModule(module);
		log.setOperator(person);
		super.save(log);
	}
	
	public int batchRemove(java.io.Serializable[] ids)
	{
		return this.getDao().batchRemove(ids);
	}
	
	public 	void saveLogItem(LogItem item)
	{
		this.getDao().saveLogItem(item);
	}
	
	
	public PaginationSupport pageListLogItem(PaginationSupport page,Integer logid)
	{
		DetachedCriteria criteria = DetachedCriteria.forClass(LogItem.class);
		criteria.add(Restrictions.eq("log.id", logid))
					.addOrder(Order.desc("id"));
		return super.listByPage(criteria, page);
	}

	@Override
	public boolean getSearchName(Class class1, String name) {
		
		return this.getDao().getSearchName(class1, name);
	}

	@Override
	public boolean getSearchName1(Class class1, String type, String name) {
		
		return this.getDao().getSearchName1(class1, type, name);
	}

	@Override
	public Integer delLog() {
		// TODO Auto-generated method stub
		return this.getDao().delLog();
	}

	@Override
	public List<Log> ByPersons(Person per) {
		// TODO Auto-generated method stub
		return this.getDao().ByPersons(per);
	}
}
